def calc_avg():
    total = 0
    length = 0
    while True:
        try:
            avg = yield total / length
        except ZeroDivisionError:
            avg = yield 0
        total += avg
        length += 1
"""
my_avg = calc_avg()
next(my_avg)
print(my_avg.send(4))
print(my_avg.send(5))
print(my_avg.send(6))
"""
def total(my_avg, value):
    avg = my_avg.send(value)
    print(f"avg value: {avg}")

if __name__ == "__main__":
    my_avg = calc_avg()
    my_avg.send(None)
    while True:
        read = input("input: ")
        read = int(read)
        if read == 0:
            break
        total(my_avg, read)